angular.module('wings-frog-directive', [])

.directive 'wfdHeartShape', ->
    restrict: 'E'
    scope: {
        score:'='
    }
    templateUrl: 'templates/wfd-heart-shape.tpl/wfd-heart-shape.tpl.html'
    link: ($scope, $element)->
        hearts = $element.find('span')
        heartElms = _.map hearts, (e) -> angular.element(e)
        $scope.show = (i) ->
            $scope.score = i
            _.each heartElms, (heart, index) ->
                if index < i
                    heart.removeClass 'love-it-off'
                    heart.addClass 'love-it-on'
                else
                    heart.removeClass 'love-it-on'
                    heart.addClass 'love-it-off'

.directive 'wfdHeartShapeShow', ->
    restrict: 'E'
    scope: {
        score:'='
    }
    templateUrl: 'templates/wfd-heart-shape-show.tpl/wfd-heart-shape-show.tpl.html'
    link: ($scope, $element)->
